package mlProject;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;


public class DocModelWriter {
	public static void writeToFile(ArrayList<DocModel> docs,String fileName){
		File file_out = new File(fileName);
		try {
			BufferedWriter bw_out = new BufferedWriter(new FileWriter(file_out, false));
			for(int i=0;i<docs.size();i++){
				DocModel doc=docs.get(i);
				bw_out.write(doc.id);
				for(int j=0;j<doc.features.size();j++){
					bw_out.write(" "+doc.features.get(j).name+":"+doc.features.get(j).value);
				}
				bw_out.write(" #label#:"+doc.label);
				bw_out.newLine();
				
			}
			bw_out.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}//
	}
}
